
package ro.qi.framework.sys.scheduler.entities;

import java.util.Date;

import ro.qi.framework.sys.entities.Entity;

public class SchedulerTask extends Entity {

	public static final int STATE_IDLE			= 1;
	public static final int STATE_RUNNING		= 2;
	
	public static final int STATE_RESCHEDULED	= 3;	// rescheduled because of fail
	public static final int STATE_STOPED		= 4;	// stoped because of too many failed attempts

	public static final int[] STATES = new int[] {
		STATE_IDLE,
		STATE_RUNNING 
	};

	public SchedulerTask() {
		super();
	}

	public SchedulerTask(int taskId) {
		super();
		setId(taskId);
		select();
	}

	public void setId(int value) {
		setValue("id", value);
	}

	public int getId() {
		return getIntValue("id");
	}

	public void setName(String value) {
		setValue("name", value);
	}

	public String getName() {
		return getStringValue("name");
	}

	public void setCommand(String value) {
		setValue("command", value);
	}

	public String getCommand() {
		return getStringValue("command");
	}

	public void setParameters(String value) {
		setValue("parameters", value);
	}

	public String getParameters() {
		return getStringValue("parameters");
	}

	public void setStartTime(Date value) {
		setValue("startTime", value);
	}

	public Date getStartTime() {
		return getDateValue("startTime");
	}

	public void setInterval(int value) {
		setValue("interval", value);
	}

	public int getInterval() {
		return getIntValue("interval");
	}

	public void setRetryAttempts(int value) {
		setValue("retryAttempts", value);
	}

	public int getRetryAttempts() {
		return getIntValue("retryAttempts");
	}

	public void setFailedAttempts(int value) {
		setValue("failedAttempts", value);
	}

	public int getFailedAttempts() {
		return getIntValue("failedAttempts");
	}

	public void setRetryInterval(int value) {
		setValue("retryInterval", value);
	}

	public int getRetryInterval() {
		return getIntValue("retryInterval");
	}

	public void setPriority(int value) {
		setValue("priority", value);
	}

	public int getPriority() {
		return getIntValue("priority");
	}

	public void setState(int value) {
		setValue("state", value);
	}

	public int getState() {
		return getIntValue("state");
	}

	public void setIsActive(boolean value) {
		setValue("isActive", value);
	}

	public boolean isActive() {
		return getBooleanValue("isActive");
	}

	public void setDescription(String value) {
		setValue("description", value);
	}

	public String getDescription() {
		return getStringValue("description");
	}

	public Date getCreatedTime() {
		return getDateValue("createdTime");
	}

	public Date getUpdatedTime() {
		return getDateValue("updatedTime");
	}

}
